﻿/******************************************************************************
 * 
 * Announce: CSharpKit, Basic algorithms, components and definitions.
 *           Copyright (C) ShenYongchen.
 *           All rights reserved.
 *   Author: 申永辰.郑州 (shenyczz@163.com)
 *  WebSite: http://github.com/shenyczz/CSharpKit
 *
 * THIS CODE IS LICENSED UNDER THE MIT LICENSE (MIT).
 * THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF 
 * ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
 * IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
 * PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
 * 
******************************************************************************/

namespace CSharpKit.Numerics.LinearAlgebra
{
    // Matrix.Operators（操作符）
    partial class Matrix<T>
    {
        public static Matrix<T> operator +(Matrix<T> rhs)
        {
            return rhs.Clone();
        }
        public static Matrix<T> operator -(Matrix<T> rhs)
        {
            return rhs.Negate();
        }



        #region Add(+)

        public static Matrix<T> operator +(Matrix<T> lhs, T scalar)
        {
            return lhs.Add(scalar);
        }
        public static Matrix<T> operator +(T scalar, Matrix<T> rhs)
        {
            return rhs.Add(scalar);
        }
        public static Matrix<T> operator +(Matrix<T> lhs, Matrix<T> rhs)
        {
            return lhs.Add(rhs);
        }

        #endregion

        #region Subtract(-)

        public static Matrix<T> operator -(Matrix<T> lhs, T scalar)
        {
            return lhs.Subtract(scalar);
        }
        public static Matrix<T> operator -(T scalar, Matrix<T> rhs)
        {
            return rhs.SubtractFrom(scalar);
        }
        public static Matrix<T> operator -(Matrix<T> lhs, Matrix<T> rhs)
        {
            return lhs.Subtract(rhs);
        }

        #endregion

        #region Multiply(*)

        public static Matrix<T> operator *(Matrix<T> lhs, T scalar)
        {
            return lhs.Multiply(scalar);
        }
        public static Matrix<T> operator *(T scalar, Matrix<T> rhs)
        {
            return rhs.Multiply(scalar);
        }
        public static Matrix<T> operator *(Matrix<T> lhs, Matrix<T> rhs)
        {
            return lhs.Multiply(rhs);
        }

        #endregion

        #region Divide(/)

        public static Matrix<T> operator /(Matrix<T> dividend, T divisor)
        {
            return dividend.Divide(divisor);
        }
        public static Matrix<T> operator /(T dividend, Matrix<T> divisor)
        {
            return divisor.DivideByThis(dividend);
        }

        #endregion

        #region Modulo(%)

        public static Matrix<T> operator %(Matrix<T> dividend, T divisor)
        {
            return dividend.Remainder(divisor);
        }
        public static Matrix<T> operator %(T dividend, Matrix<T> divisor)
        {
            return divisor.RemainderByThis(dividend);
        }
        public static Matrix<T> operator %(Matrix<T> dividend, Matrix<T> divisor)
        {
            return dividend.PointwiseRemainder(divisor);
        }

        #endregion


        //
        // 逐点运算
        //
        public static Matrix<T> Abs(Matrix<T> x)
        {
            return x.PointwiseAbs();
        }





        //}}@@@
    }


}

